{% extends "admin/change_form.html" %}

{% block extrahead %}{{ block.super }}
<script type="text/javascript" src="../../../jsi18n/"></script>
<script type="text/javascript" src="/media/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/media/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="/media/tiny_mce/jquery.tinymce.js"></script>

<script type="text/javascript">
var tTinyMCE_init = false;

function initTinyMCE() {
  $('textarea#id_body, textarea#id_more').tinymce({
     theme: "advanced",
     theme_advanced_toolbar_location: "top",
     theme_advanced_toolbar_align: "left",
     height: "400",
     width: "100%"
  });
  tTinyMCE_init = true;
};

function enableTinyMCE() {
  if (tTinyMCE_init) {
    $('textarea#id_body').tinymce().show();
    $('textarea#id_more').tinymce().show();
  } else {
    initTinyMCE();
  }
};

function disableTinyMCE() {
  if (tTinyMCE_init) {
    $('textarea#id_body').tinymce().hide();
    $('textarea#id_more').tinymce().hide();
  };
};

function toggleTinyMCE() {
  var markup = $('select#id_markup').val();
  if (markup == 'html') {
     enableTinyMCE();
  } else {
     disableTinyMCE();
  };
};

$().ready(function() {
  toggleTinyMCE();
  
  $('select#id_markup').change(function () {
    toggleTinyMCE();
  });
});
</script>
{{ media }}
{% endblock %}
